< previous page page_189 next page >

Page 189
the mask onto the destination image using the vbMergePaint opcode. This blanks out the portions of the destination that correspond to the black parts of the mask.
Finally, copy the source image onto the destination using the vbSrcAnd opcode. Where the destination image is white, including the areas blanked by the mask, the source image appears. In places where the source image is white, the destination image remains unchanged.
Example program Compose, shown in Figure 6.14, automates part of this process. The program places the foreground image in the upper right on top of the background picture in the upper left. Initially, the foreground picture has a magenta background. The program examines this image's upper-left pixel to find out what color should be transparent in the image.
The program then examines the foreground picture's pixels to make a mask image. When it finds a magenta pixel, it changes the foreground pixel to white and gives the mask picture a white pixel. When it sees any other color pixel, the program leaves the foreground pixel unchanged and gives the mask picture a black pixel. The result for these two pictures is shown in the upper right and lower left in Figure 6.14.
After creating the mask, the program uses the PaintPicture techniques described in Chapter 1 to display the overlaid result.
You can create similar effects directly using image processing techniques. Create foreground and background images as before. The program uses the GetBitmapPixels sub-
0189-01.jpg
Figure 6.14
Program Compose merges two images.

 
< previous page page_189 next page >